package io.renren.modules.lucky.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.lucky.entity.AppWxUserEntity;
import io.renren.modules.lucky.service.AppWxUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * app端-微信-用户信息表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-11-07 22:58:28
 */
@RestController
@RequestMapping("lucky/appwxuser")
public class AppWxUserController {
    
    @Autowired
    private AppWxUserService appWxUserService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("lucky:appwxuser:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = appWxUserService.queryPage(params);
        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("lucky:appwxuser:info")
    public R info(@PathVariable("id") Integer id){
		AppWxUserEntity appWxUser = appWxUserService.getById(id);
        return R.ok().put("appWxUser", appWxUser);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("lucky:appwxuser:save")
    public R save(@RequestBody AppWxUserEntity appWxUser){
		appWxUserService.save(appWxUser);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("lucky:appwxuser:update")
    public R update(@RequestBody AppWxUserEntity appWxUser){
		appWxUserService.updateById(appWxUser);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("lucky:appwxuser:delete")
    public R delete(@RequestBody Integer[] ids){
		appWxUserService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
